#include <inttypes.h>

typedef struct FileCorruptedInfo {
  uint32_t code;
} FileCorruptedInfo;

typedef struct IoErrorInfoDetails {
  uint32_t code;
} IoErrorInfoDetails;

typedef struct IoErrorInfo {
  struct IoErrorInfoDetails details;
} IoErrorInfo;

typedef enum DatabaseError_Tag {
  /**
   * Denotes an error when the user attempted a write operation.
   */
  IsReadOnly,
  /**
   * Denotes an error when the user should read the error code for what it was.
   */
  IoError,
  /*
   * Denotes an error when the user should run a repair tool to recover it.
   */
  FileCorrupted,
} DatabaseError_Tag;

typedef struct DatabaseError {
  DatabaseError_Tag tag;
  union {
    struct IoErrorInfo io_error;
    struct FileCorruptedInfo file_corrupted;
  };
} DatabaseError;

/**
 * Converts a 'DatabaseError' value to *mut libc::c_char.
 *
 * # Safety
 *
 * This is an unsafe operation because it dereferences a passed pointer.
 */
char* db_error_description(const struct DatabaseError* error);
